package org.hyl.javabase.model;

public class factoryDemo {
	public static void main(String[] args) {
		SendFactory factory = new SendFactory();

//		SmsSender ss1 = new SmsSender();
//		Sender ss2 = new SmsSender();
//		receiver ss3 = new SmsSender();
//		ss1.Send();
//		ss1.receive();
//		ss2.Send();
//		ss3.receive();
		// ss=new MailSender();
		Sender sender = factory.produce("sms");
		sender.Send();
	}
}

interface Sender {
	void Send();
}

interface receiver {
	void receive();

}

class MailSender implements Sender, receiver {
	public MailSender() {
	}

	public void Send() {
		System.out.println("this is mailsender!");
	}

	public void receive() {
		System.out.println("this is mailreceive!");

	}
}

class SmsSender implements Sender, receiver {

	public void Send() {
		System.out.println("this is sms sender!");
	}

	public void receive() {
		System.out.println("this is Sms receive!");

	}
}

class SendFactory {

	public Sender produce(String type) {
		if ("mail".equals(type)) {
			return new MailSender();
		} else if ("sms".equals(type)) {
			return new SmsSender();
		} else {
			System.out.println("��������ȷ������!");
			return null;
		}
	}
}